﻿using CodingBlog.UI.Test.Helpers;
using NUnit.Framework;

namespace CodingBlog.UI.Test
{
    [TestFixture]
    class RouteTableTests
    {
        [Test]
        public void UrlWhenSlash_RedirectToPostList()
        {
            string url = "~/";
            RouteHelpers.TestRoute(url, new
            {
                Controller = "Post",
                Action = "List",
                Year = string.Empty,
                Month = string.Empty,
                Day = string.Empty
            });
        }

        [Test]
        public void UrlWhenFullDateAndPostName_RedirectToPostDetailsByDateAndName()
        {
            string url = "~/2011/03/22/post-name";
            RouteHelpers.TestRoute(url, new
            {
                Controller = "Post",
                Action = "Details",
                Year = "2011",
                Month = "03",
                Day = "22",
                PostName = "post-name"
            });
        }

        [Test]
        public void UrlWhenFullDate_RedirectToPostListByFullDate()
        {
            string url = "~/2011/03/22";
            RouteHelpers.TestRoute(url, new
            {
                Controller = "Post",
                Action = "List",
                Year = "2011",
                Month = "03",
                Day = "22"
            });

        }

        [Test]
        public void UrlWhenYearMonth_RedirectToPostListByYearMonth()
        {
            string url = "~/2011/03";
            RouteHelpers.TestRoute(url, new
            {
                Controller = "Post",
                Action = "List",
                Year = "2011",
                Month = "03",
                Day = string.Empty
            });
        }

        [Test]
        public void UrlWhenYear_RedirectToPostListByYear()
        {
            string url = "~/2011";
            RouteHelpers.TestRoute(url, new
            {
                Controller = "Post",
                Action = "List",
                Year = "2011",
                Month = string.Empty,
                Day = string.Empty
            });
        }

        [Test]
        public void UrlWhenTagTagName_RedirectToPostListByTag()
        {
            string url = "~/Tag/tag-name";
            RouteHelpers.TestRoute(url, new
            {
                Controller = "Post",
                Action = "ListPerTag",
                Tag = "tag-name"
            });
        }

        [Test]
        public void UrlWhenCBAdmin_RedirectToAdminIndex()
        {
            string url = "~/cb-admin";
            RouteHelpers.TestRoute(url, new { Controller = "Admin", Action = "Index" });
        }

        [Test]
        public void UrlWhenInstall_RedirectToInstallIndex()
        {
            string url = "~/install";
            RouteHelpers.TestRoute(url, new { Controller = "Install", Action = "Index" });
        }

        [Test]
        public void UrlWhenInstallSomeAction_RedirectToInstallSomeAction()
        {
            string url = "~/install/SomeAction";
            RouteHelpers.TestRoute(url, new { Controller = "Install", Action = "SomeAction" });
        }
    }
}
